home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / header.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  65 lines

  1. // HEADER.CPP
  2.  
  3. #include "header.h"
  4.  
  5. Header::Header(char* h, int ln, BORDERS type, int pat)
  6.     {
  7.     header = (*h) ? strdup(h) : NULL;
  8.     len = ln;
  9.     hdr_pattern = pat;
  10.     hdr_b_type = type;
  11.     }
  12. ////////////////////////////
  13. void Header::show(loc begin)
  14.     {
  15.     if(header == NULL)
  16.     return;
  17.  
  18.     int lh = begin.X + area[hdr_b_type].origin.X + area[hdr_b_type].corner.X
  19.         + ((!len) ? textwidth(header) : len);
  20.     int lv = begin.Y + area[hdr_b_type].origin.Y + area[hdr_b_type].corner.Y
  21.         + pScreenSet->standart_height + 2;
  22.  
  23.     bar(begin.X + area[hdr_b_type].origin.X,
  24.       begin.Y + area[hdr_b_type].origin.Y,
  25.       lh - area[hdr_b_type].corner.X,
  26.       lv - area[hdr_b_type].corner.Y,
  27.       pColorSet->colors.HDR_BAK_COLOR,
  28.           pColorSet->colors.FILL_COLOR, (uchar*)pattern[hdr_pattern]);
  29.  
  30.     Carcase::show(hdr_b_type, rect(begin, loc(lh, lv)), 0);
  31.     if(textwidth(header) > len)
  32.         return;
  33.     settextjustify(CENTER_TEXT, CENTER_TEXT);
  34.     setcolor(pColorSet->colors.HDR_ATTR_COLOR);
  35.     outtextat(loc((begin.X + lh) / 2,
  36.         begin.Y + area[hdr_b_type].origin.Y
  37.         + (pScreenSet->standart_height + 2) / 2), header);
  38.     }
  39. ///////////////////////////////
  40. /*
  41. void demo()
  42.     {
  43.     Header h("HELLO, World !", 140, BUTTON_BORDER, 16);
  44.     h.show(loc(10, 10));
  45.     Header h1("HELLO, World !", 150, STANDART_BORDER, 16);
  46.     h1.show(loc(10, 50));
  47.     Header h2("HELLO, World !", 160, PRESS_BORDER, 16);
  48.     h2.show(loc(10, 100));
  49.     Header h3("HELLO, World !", 170, SHOW_BORDER, 16);
  50.     h3.show(loc(10, 150));
  51.     }
  52.  
  53. void main()
  54.     {
  55.     if(!init_KNOW_HOW())
  56.         return;
  57.     demo();
  58.     pColorSet->loadColorSet(1);
  59.     demo();
  60.     pColorSet->loadColorSet(2);
  61.     demo();
  62.     close_KNOW_HOW();
  63.     closegraph();
  64.     }
  65. */